﻿using Appliaction.Dto.DB;
using Appliaction.IAppServices.DB;
using AutoMapper;
using Domain.Entitys.DB;
using Domain.IRepositorys.DB;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Appliaction.AppServices.DB
{
   /// <summary>
   /// Appliaction下面的仓库库位(实现Domain下面的接口)
   /// </summary>
    public class Db_warehouse_locationServices : IDb_warehouse_locationServices
    {
        private readonly DB_warehouse_location _db_warehouse_location;
        
        private readonly IMapper _mapper;
       
        public Db_warehouse_locationServices(DB_warehouse_location db_warehouse_location, IMapper mapper)
        {
            _db_warehouse_location = db_warehouse_location;
            _mapper = mapper;
        }

       /// <summary>
       /// 查询仓库库位总数量
       /// </summary>
       /// <param name="zone_code"></param>
       /// <param name="location_code"></param>
       /// <param name="location_name"></param>
       /// <param name="location_x_position"></param>
       /// <param name="location_y_position"></param>
       /// <param name="location_z_position"></param>
       /// <returns></returns>
       /// <exception cref="NotImplementedException"></exception>
        public int Select_count_warehouse_zone(string zone_code, string location_code, string location_name, int location_x_position, int location_y_position, int location_z_position)
        {
            return _db_warehouse_location.Select_count_warehouse_location(zone_code, location_code, location_name, location_x_position, location_y_position, location_z_position);
        }
        /// <summary>
        /// 分页查询仓库库位列表
        /// </summary>
        /// <param name="zone_code"></param>
        /// <param name="location_code"></param>
        /// <param name="location_name"></param>
        /// <param name="location_x_position"></param>
        /// <param name="location_y_position"></param>
        /// <param name="location_z_position"></param>
        /// <param name="currentPage"></param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public List<Warehouse_location> Select_fy_warehouse_zone(string zone_code, string location_code, string location_name, int location_x_position, int location_y_position, int location_z_position, int currentPage, int pageSize)
        {
           return _db_warehouse_location.Select_fy_warehouse_location(zone_code, location_code, location_name, location_x_position, location_y_position, location_z_position, currentPage, pageSize);
        }

  

        /// <summary>
        /// 仓库库位冻结状态
        /// </summary>
        /// <param name="id"></param>
        /// <param name="location_freeze"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public Task<int> warehouse__location_Frozenstate(int id, char location_freeze)
        {
            return _db_warehouse_location.warehouse__location_Frozenstate(id, location_freeze);
        }

        /// <summary>
        /// 库位编码唯一性验证
        /// </summary>
        /// <param name="warehouse_code"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public Task<int> Warehouse_Location_code_judgment(string location_code, string zone_code)
        {
            return _db_warehouse_location.Warehouse_Location_code_judgment(location_code, zone_code);
        }
        /// <summary>
        /// 库位名称唯一性检测
        /// </summary>
        /// <param name="warehouse_name"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public Task<int> Warehouse_Location_name_judgment(string location_name, string zone_code)
        {
            return _db_warehouse_location.Warehouse_Location_name_judgment(location_name, zone_code);
        }
        /// <summary>
        /// 添加库位
        /// </summary>
        /// <param name="db_Warehouse_LocationAddDto"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public async Task<int> warehouse_location_Add(Db_Warehouse_locationAddDto db_Warehouse_LocationAddDto)
        {
            var warhouse_location = _mapper.Map<Warehouse_location>(db_Warehouse_LocationAddDto);
            return await _db_warehouse_location.warehouse_location_Add(warhouse_location);
        }
        /// <summary>
        /// 修改库位信息
        /// </summary>
        /// <param name="db_Warehouse_LocationUpdateDto"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public async Task<int> warehouse__location_Update(Db_Warehouse_locationUpdateDto db_Warehouse_LocationUpdateDto)
        {
            var warhouse_location = _mapper.Map<Warehouse_location>(db_Warehouse_LocationUpdateDto);
            return await _db_warehouse_location.warehouse__location_Update(warhouse_location);
        }
        /// <summary>
        /// 库位删除
        /// </summary>
        /// <param name="zone_code"></param>
        /// <param name="location_code"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public Task<int> warehouse_location_tombstone(string zone_code, string location_code)
        {
            return _db_warehouse_location.warehouse_location_tombstone(zone_code, location_code);
        }
        /// <summary>
        /// 查询库位
        /// </summary>
        /// <param name="zone_code"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public List<Warehouse_location> warehouse_location_Async(string zone_code)
        {
           return _db_warehouse_location.warehouse_location_Async(zone_code);
        }

        /// <summary>
        /// 判断库位的添加是否大于库区的容量
        /// </summary>
        /// <param name="warehouse_code"></param>
        /// <param name="zone_capacity"></param>
        /// <returns></returns>
        public Task<int> Warehouselocation_Capacity_judgment(string zone_code, int location_max_capacity) { 
        
        return _db_warehouse_location.Warehouselocation_Capacity_judgment(zone_code, location_max_capacity);
        }


        /// <summary>
        /// 修改查询仓库名称
        /// </summary>
        /// <param name="location_name"></param>
        /// <param name="zone_code"></param>
        /// <param name="location_code"></param>
        /// <returns></returns>
        public Task<int> Warehouse_Location_name_UpdateJudgment(string location_name, string zone_code, string location_code) { 
        
        return _db_warehouse_location.Warehouse_Location_name_UpdateJudgment(location_name, zone_code, location_code);
        }


        /// <summary>
        /// 结构编码查询仓库信息
        /// </summary>
        /// <param name="warehouse_code"></param>
        /// <returns></returns>
        public List<Warehouse_location> Warehouse_location_By_Select_Async_code(string zone_code, string location_code) { 
        
        return _db_warehouse_location.Warehouse_location_By_Select_Async_code(zone_code, location_code);
        }


        /// <summary>
        /// 修改的容量判断
        /// </summary>
        /// <param name="zone_code"></param>
        /// <param name="location_code"></param>
        /// <param name="new_location_max_capacity"></param>
        /// <returns></returns>
      public  Task<int> Warehouselocation_Capacity_UpdateJudgment(string zone_code, string location_code, int new_location_max_capacity) { 
        
       return _db_warehouse_location.Warehouselocation_Capacity_UpdateJudgment(zone_code, location_code, new_location_max_capacity);
      }


    }
}
